import math
def nc_acm_calculate_grade1(data_list):
    data_list_cp = data_list.copy()
    try :
        data_list_cp[0]["ranking"] = 1
    except :
        print("序列为空,请检查")
    for index in range(1,len(data_list)) :
        if data_list_cp[index]["ac_number"] == data_list_cp[index-1]["ac_number"] and data_list_cp[index]["time"] == data_list_cp[index-1]["time"]:
            data_list_cp[index]["ranking"] = data_list_cp[index-1]["ranking"]
        else:
            data_list_cp[index]["ranking"] = data_list_cp[index-1]["ranking"] + 1
    point_3_min_rank = math.ceil(len(data_list) * 0.2)
    point_2_min_rank = math.ceil(len(data_list) * 0.5)
    for index in range(len(data_list_cp)):
        if data_list_cp[index]["ranking"] <= point_3_min_rank:
            data_list[index]["grade1"] = 3
        elif data_list_cp[index]["ranking"] <= point_2_min_rank:
            data_list[index]["grade1"] = 2
        else:
            data_list[index]["grade1"] = 1
    return data_list

if __name__ == "__main__":
    data_list = [
        {"ac_number": 0 , "time": 0 },
        {"ac_number": 1 , "time": 0 }
    ]
    data_list = nc_acm_calculate_grade1(data_list)
    print(data_list)